package threadlocal;

import org.smart4j.framework.MyThreadLocal;

/**
 * 〈一句话功能简述〉<br>
 *
 * @author andy
 * @version V1.0
 * @date 18/2/1 下午5:29
 */
public class SequenceImpl3 implements Sequence{

    private static MyThreadLocal<Integer> local = new MyThreadLocal<Integer>(){
        @Override
        protected Integer initialValue() {
            return 0;
        }
    };

    @Override
    public int getSequence() {
        local.set(local.get() + 1);
        return local.get();
    }

    public static void main(String[] args) {
        Sequence sequence = new SequenceImpl3();

        ClientThread clientThread1 = new ClientThread(sequence);
        ClientThread clientThread2 = new ClientThread(sequence);
        ClientThread clientThread3 = new ClientThread(sequence);

        clientThread1.start();
        clientThread2.start();
        clientThread3.start();
    }

}
